home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
106_01
/
ntoi.c
< prev
next >
Wrap
Text File
|
1980-07-08
|
512b
|
23 lines
/*
this function converts ascii characters to an integer.
most common number bases may be used (except offset
octal).
*/
ntoi(n,b)
char *n;
int b;
{
int val,sign;
char c;
val=0; sign=1;
while ((c = *n) == '\t' || c == ' ') ++n;
if (c == '-') {sign = -1; n++;}
while (dig(c = *n++)) {
if (b == 16 && c >= 'A' && c <= 'F') c -= 7;
val = val * b + c - '0';
}
return sign*val;
}